<?php
namespace App\Transformers;

use League\Fractal\TransformerAbstract;
use App\Model\Order;

class OrderTransformer extends TransformerAbstract{

    private static $status = [
        'un_pay' => '未支付',
        'payed' => '已支付',
//        'shiped' => '已上菜',
//        'shiped_not_pay' => '已上菜还未付款',
        'complete' => '已完成',
//        'commented' => '已评价'
    ];

    private static $order_status = [
        'un_order' => '未完成',
        'ordered' => '完成'
    ];

    private static $comment_status = [
        'un_comment' => '未评价',
        'commented' => '已评价'
    ];

    public function transform(Order $item){
        return [
            'id' => $item->id,
            'user_id' => $item->user_id,
            'order_number' => $item->order_number,
//            'total_amount' => $item->total_amount,
            'status' => OrderTransformer::$status[$item->status],
            'order_status' => OrderTransformer::$order_status[$item->order_status],
            'bistro_id' =>$item->bistro_id,
            'position_id' => $item->position_id,
            'sort_number' => $item->sort_number,
            'remarks' => $item->remarks,
            'created_at' =>$item->created_at->toDateTimeString(),
        ];
    }
}